package com.ruoyi.web.controller.situation;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.config.domain.Datarulesconfig;
import com.ruoyi.config.service.IDatarulesconfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 规则配置Controller
 * 
 * @author ruoyi
 * @date 2024-12-14
 */
@RestController
@RequestMapping("/control/datarulesconfig")
public class DatarulesconfigController extends BaseController
{
    @Autowired
    private IDatarulesconfigService datarulesconfigService;

    /**
     * 查询规则配置列表
     */
    @PreAuthorize("@ss.hasPermi('control:datarulesconfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(Datarulesconfig datarulesconfig)
    {
        startPage();
        List<Datarulesconfig> list = datarulesconfigService.selectDatarulesconfigList(datarulesconfig);
        return getDataTable(list);
    }

    /**
     * 导出规则配置列表
     */
    @PreAuthorize("@ss.hasPermi('control:datarulesconfig:export')")
    @Log(title = "规则配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Datarulesconfig datarulesconfig)
    {
        List<Datarulesconfig> list = datarulesconfigService.selectDatarulesconfigList(datarulesconfig);
        ExcelUtil<Datarulesconfig> util = new ExcelUtil<Datarulesconfig>(Datarulesconfig.class);
        util.exportExcel(response, list, "规则配置数据");
    }

    /**
     * 获取规则配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('control:datarulesconfig:query')")
    @GetMapping(value = "/{ruleId}")
    public AjaxResult getInfo(@PathVariable("ruleId") String ruleId)
    {
        return success(datarulesconfigService.selectDatarulesconfigByRuleId(ruleId));
    }

    /**
     * 新增规则配置
     */
    @PreAuthorize("@ss.hasPermi('control:datarulesconfig:add')")
    @Log(title = "规则配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Datarulesconfig datarulesconfig)
    {
        return toAjax(datarulesconfigService.insertDatarulesconfig(datarulesconfig));
    }

    /**
     * 修改规则配置
     */
    @PreAuthorize("@ss.hasPermi('control:datarulesconfig:edit')")
    @Log(title = "规则配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Datarulesconfig datarulesconfig)
    {
        return toAjax(datarulesconfigService.updateDatarulesconfig(datarulesconfig));
    }

    /**
     * 删除规则配置
     */
    @PreAuthorize("@ss.hasPermi('control:datarulesconfig:remove')")
    @Log(title = "规则配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ruleIds}")
    public AjaxResult remove(@PathVariable String[] ruleIds)
    {
        return toAjax(datarulesconfigService.deleteDatarulesconfigByRuleIds(ruleIds));
    }
}
